#pragma once
#include "stdafx.h"
#include <UIRibbon.h>
#include <string>
#include <map>
#include <vector>

using namespace std;

 MIDL_INTERFACE("56216592-9e6f-472d-9146-e23d011a488c")
    IPropertyKeyItem : public IUnknown
    {
    public:
		virtual HRESULT STDMETHODCALLTYPE Initialize(REFPROPERTYKEY propertyKey, PCWSTR propertyKeyName); 
		virtual HRESULT STDMETHODCALLTYPE GetPropertyKey(PROPERTYKEY *propertyKey);
    };

	template<>
	struct less<PROPERTYKEY>
		: public binary_function<PROPERTYKEY, PROPERTYKEY, bool>
	{	// functor for operator<
	bool operator()(const PROPERTYKEY& _Left, const PROPERTYKEY& _Right) const
		{	// apply operator< to operands
			return (memcmp(&_Left, &_Right, sizeof(PROPERTYKEY)) < 0);
		}
	};

class CPropertyKeyItem : public CComObjectRootEx<CComMultiThreadModel>, public IUISimplePropertySet, public IPropertyKeyItem
{
private:
	wstring m_propertyKeyName;
	PROPERTYKEY m_propertyKey; 

	static map<PROPERTYKEY, wstring> s_propertyKeyMap;
	static void InitPropertyKeyMap();

public:
	BEGIN_COM_MAP(CPropertyKeyItem)
        COM_INTERFACE_ENTRY(IUISimplePropertySet)
		COM_INTERFACE_ENTRY(IPropertyKeyItem)
    END_COM_MAP()

	STDMETHOD(Initialize)(REFPROPERTYKEY propertyKey, PCWSTR propertyKeyName); 
	STDMETHOD(GetPropertyKey)(PROPERTYKEY *propertyKey);
	STDMETHOD(GetValue)(__in REFPROPERTYKEY key, __out PROPVARIANT *ppropvar);

	static const map<PROPERTYKEY, wstring> &GetPropertyKeyMap() { InitPropertyKeyMap(); return s_propertyKeyMap; }
	static const wstring &GetPropertyKeyName(REFPROPERTYKEY propertyKey) { return s_propertyKeyMap[propertyKey]; }
	
	CPropertyKeyItem(void);
	virtual ~CPropertyKeyItem(void);
};
